package com.kevin.actoviti.day01;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;

import java.util.List;

/**
 * @Classname QueryProcessDefinition
 * @Description TODO
 * @Date 2020/6/21 15:50
 * @Created by kevin
 */
public class QueryProcessDefinition {

    public static void main(String[] args) {

        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        List<ProcessDefinition> processDefinitionList = processDefinitionQuery.processDefinitionKey("holiday")
                .orderByProcessDefinitionVersion()
                .desc().list();
        for (ProcessDefinition processDefinition : processDefinitionList) {
            System.out.println("流程定义ID："+processDefinition.getId());
            System.out.println("流程定义名称："+processDefinition.getName());
            System.out.println("流程定义key："+processDefinition.getKey());
            System.out.println("流程定义版本号："+processDefinition.getVersion());
            System.out.println("流程部署的ID："+processDefinition.getDeploymentId());
        }

    }
}
